import pygame

from Actor.Lead_actor import Lead_Actor
from Dialog.ActorDialog import CaptionDialog
from Dialog.TunnelTaskDialog import TunnelTask1BeginDialog


def step15_show_dialog():
    """
    step15_show_dialog
    :return:
    """
    # 初始化pygame
    pygame.init()
    # 获取游戏时钟
    clock = pygame.time.Clock()
    # 创建游戏的窗口 640 * 236 根据要显示图片的大小设置
    screen = pygame.display.set_mode((1280, 720), 0, 32)
    # 加载图片文件
    background = pygame.image.load("../Resources/tmx/map2-1.png").convert()
    font = pygame.font.Font("../Resources/font/迷你简粗宋.TTF", 20)
    actor = Lead_Actor(50, 100)
    sys_dialog = TunnelTask1BeginDialog(font)
    actor_dialog = CaptionDialog(actor, font)
    while True:
        # 游戏循环
        for event in pygame.event.get():
            # 关闭事件，进行退出处理
            if event.type == pygame.QUIT:
                exit()
            elif event.type == pygame.KEYDOWN:
                sys_dialog.next_text()
                actor_dialog.next_text()
        # 绘制图片到显示窗口
        screen.blit(background, (0, 0))
        actor.draw(screen, 0, 0)
        sys_dialog.draw(screen)

        actor_dialog.draw(screen, 0, 0)
        # 通过时钟对象指定循环频率
        clock.tick(20)
        # 调用flip方法更新显示,也可以使用update方法
        pygame.display.flip()


if __name__ == '__main__':
    step15_show_dialog()
